#include "EngineHeader.h"
#include "Event.h"

namespace LSH
{
namespace GUI
{

Event::Event(const String& eventName)
{
    _name = eventName;
}


Event::~Event(void)
{
    SoltItr itr = _solts.begin();
    SoltItr endItr = _solts.begin();
    while(itr != endItr){
        delete *itr;
        ++itr;
    }
    _solts.clear();
}


bool Event::subscribe(SlotFunctorBase* slot)
{
    _solts.push_back(slot);
    return true;
}
	
String Event::getName() const
{
    return _name;
}

void Event::operator()(EventArgs& args)
{
    SoltItr itr = _solts.begin();
    SoltItr endItr = _solts.begin();
    while(itr != endItr){
        args.handled |= (*(*itr))(args);
        ++itr;
    }
}


} // GUI
} // LSH